from django.urls import path
from . import views
from . import stop_loss_views
from . import monitoring_views

app_name = 'portfolios'

urlpatterns = [
    # 投资组合
    path('', views.PortfolioListCreateView.as_view(), name='portfolio_list'),
    path('<int:pk>/', views.PortfolioDetailView.as_view(), name='portfolio_detail'),
    
    # 投资组合持仓
    path('<int:portfolio_id>/holdings/', views.PortfolioHoldingListView.as_view(), name='portfolio_holdings'),
    
    # 交易记录
    path('<int:portfolio_id>/transactions/', views.TransactionListCreateView.as_view(), name='portfolio_transactions'),
    
    # 止损设置 (原有的基础CRUD)
    path('<int:portfolio_id>/stop-loss/', views.StopLossSettingListCreateView.as_view(), name='stop_loss_settings'),
    
    # 止损管理 (新的高级功能)
    path('stop-loss/create/', stop_loss_views.create_stop_loss, name='create_stop_loss'),
    path('stop-loss/list/', stop_loss_views.list_stop_loss, name='list_stop_loss'),
    path('stop-loss/<int:setting_id>/update/', stop_loss_views.update_stop_loss, name='update_stop_loss'),
    path('stop-loss/<int:setting_id>/delete/', stop_loss_views.delete_stop_loss, name='delete_stop_loss'),
    path('stop-loss/check/', stop_loss_views.check_stop_loss, name='check_stop_loss'),
    path('stop-loss/<int:setting_id>/trigger/', stop_loss_views.trigger_stop_loss, name='trigger_stop_loss'),
    path('stop-loss/statistics/', stop_loss_views.stop_loss_statistics, name='stop_loss_statistics'),
    
    # 资产配置
    path('asset-allocation/', views.asset_allocation, name='asset_allocation'),
    
    # 再平衡
    path('rebalance/', views.rebalance_portfolio, name='rebalance_portfolio'),
    
    # 业绩分析
    path('<int:portfolio_id>/performance/', views.portfolio_performance, name='portfolio_performance'),
    
    # 风险分析
    path('<int:portfolio_id>/risk-analysis/', views.portfolio_risk_analysis, name='portfolio_risk_analysis'),
    
    # 监控系统
    path('<int:portfolio_id>/monitor/allocation/', monitoring_views.monitor_portfolio_allocation, name='monitor_allocation'),
    path('<int:portfolio_id>/monitor/concentration/', monitoring_views.monitor_concentration_risk, name='monitor_concentration'),
    path('<int:portfolio_id>/monitor/performance/', monitoring_views.monitor_performance_tracking, name='monitor_performance'),
    path('monitor/check-all/', monitoring_views.check_all_portfolios, name='check_all_portfolios'),
    
    # 预警管理
    path('<int:portfolio_id>/alerts/', monitoring_views.get_portfolio_alerts, name='portfolio_alerts'),
    path('alerts/<int:alert_id>/acknowledge/', monitoring_views.acknowledge_alert, name='acknowledge_alert'),
    
    # 季度报告
    path('<int:portfolio_id>/quarterly-report/generate/', monitoring_views.generate_quarterly_report, name='generate_quarterly_report'),
    path('<int:portfolio_id>/quarterly-reports/', monitoring_views.get_quarterly_reports, name='quarterly_reports'),
    path('quarterly-reports/<int:report_id>/', monitoring_views.get_quarterly_report_detail, name='quarterly_report_detail'),
    
    # 监控统计和规则
    path('monitoring/statistics/', monitoring_views.get_monitoring_statistics, name='monitoring_statistics'),
    path('monitoring/rules/', monitoring_views.get_monitoring_rules, name='monitoring_rules'),
    path('monitoring/rules/create/', monitoring_views.create_monitoring_rule, name='create_monitoring_rule'),
]